<?php

namespace App\Http\Responses;


use Psy\Util\Json;

class ResponseDto
{
    static $SUCCESS=200;
    static $FAIL=500;

    var $res_data;
    var $code = 200;
    var $message = "";
    static function createResObj($data,$code){
        $res = new ResponseDto();
        $res->res_data = $data;
        $res->code = $code;
        return Json::encode($res);
    }

    /**
     * 将laravel的分页数据转换为 datatables 使用的数据类型
     * {recordsTotal,recordsFiltered,data}
     * @param $data
     */
    static function  convertPageToDataTableObj($datas,$total){
//        var_dump($page);
        return array(
            "recordsTotal"=>$total,
            "data"=>$datas,
            "recordsFiltered"=>$total,
        );
    }


}
